package com.javaclimb.music.service.impl;

import com.javaclimb.music.dao.RankSongMapper;
import com.javaclimb.music.dao.SongMapper;
import com.javaclimb.music.domain.RankSong;
import com.javaclimb.music.service.RankSongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 榜单里面的歌曲service实现类
 */
@Service
public class RankSongServiceImpl implements RankSongService {
    @Autowired
    private RankSongMapper rankSongMapper;
    /**
     * 增加
     *
     * @param rankSong
     */
    @Override
    public boolean insert(RankSong rankSong) {
        return rankSongMapper.insert(rankSong)>0;
    }

    /**
     * 修改
     *
     * @param rankSong
     */
    @Override
    public boolean update(RankSong rankSong) {
        return rankSongMapper.update(rankSong)>0;
    }

    /**
     * 删除
     *
     * @param id
     */
    @Override
    public boolean delete(Integer id) {
        return rankSongMapper.delete(id)>0;
    }

    /**
     * 根据歌曲id和榜单id删除
     */
    @Override
    public boolean deleteBySongIdAndRankId(Integer songId,Integer rankId){
        return rankSongMapper.deleteBySongIdAndRankId(songId,rankId)>0;
    }

    /**
     * 根据主键查询整个对象
     *
     * @param id
     */
    @Override
    public RankSong selectByPrimaryKey(Integer id) {
        return rankSongMapper.selectByPrimaryKey(id);
    }

    /**
     * 查询所有榜单里面的歌曲
     */
    @Override
    public List<RankSong> allRankSong() {
        return rankSongMapper.allRankSong();
    }

    /**
     * 根据榜单id查询所有的歌曲
     *
     * @param rankId
     */
    @Override
    public List<RankSong> rankSongOfRankId(Integer rankId) {
        return rankSongMapper.rankSongOfRankId(rankId);
    }
}
